#region

using System;
using System.ComponentModel.DataAnnotations;
using VinhSon.Intranet.Bussiness;

#endregion

namespace VinhSon.Intranet.Models
{
    [Serializable]
    public partial class UserGroupModel
    {
        #region Constructor

        public UserGroupModel()
        {
        }

        public UserGroupModel(UserGroup value)
        {
            Id = value.Id;
            Name = value.Name;
            Description = value.Description;
            IsDefaultGroup = value.IsDefaultGroup ?? false;
        }

        #endregion

        #region Fields

        private Int32? _CompanyId;

        private String _Description;

        private Int32 _Id;

        private Boolean _IsDefaultGroup;

        private String _Name;

        #endregion

        #region Properties

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                _Id = value;
            }
        }

        [Required]
        //[Range(0, 0]
        [StringLength(100)]
        public String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        [StringLength(100)]
        public String Description
        {
            get
            {
                return _Description;
            }
            set
            {
                _Description = value;
            }
        }

        //[Required]
        //[Range(0, 0]
        //[StringLength(0)]
        public Boolean IsDefaultGroup
        {
            get
            {
                return _IsDefaultGroup;
            }
            set
            {
                _IsDefaultGroup = value;
            }
        }

        #endregion

        #region Operators

        public void Update(UserGroup value)
        {
            // value.Id = Id;
            value.Name = Name;
            value.Description = Description;
            value.IsDefaultGroup = IsDefaultGroup;
        }

        public static implicit operator UserGroupModel(UserGroup obj)
        {
            return new UserGroupModel(obj);
        }

        public static implicit operator UserGroup(UserGroupModel obj)
        {
            UserGroup value = new UserGroup();
            obj.Update(value);
            return value;
        }

        #endregion
    }
}
